<?php
require_once ("core/Database.class.php");
require_once ("core/Package.class.php");

function ListPackage() {
    $db = new DataBase();
    $link = $db->connect();
    if ($result = $db->query("call PackagesList()")) {
        /* Fetch the results of the stored proceure */
         while ($obj = $result->fetch_assoc()) {
            $package = new Package($obj['id'], $obj['name'], $obj['description'], $obj['price']);
            $allpkg[] = $package;
        }
        
    }
    /* Destroy the result set and free the memory used for it */
    mysqli_free_result($result);
    $db->close();
    return $allpkg;
}

function CreatePackage($package){
  $db = new DataBase();
  $db->connect();
  $call = "call PackageCreate('".$package->get_name()."','".$package->get_desc()."','".$package->get_price()."')";
  $db->query($call); 
  $db->close();
}
?>